package net.lookyou.boot.demo.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.lookyou.boot.demo.entity.User;
import net.lookyou.boot.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> queryUserList() {
        return userMapper.queryUserList();
    }

    @Override
    public User queryUserById(int id) {
        return userMapper.queryUserById(id);
    }

    @Override
    public int addUser(User user) {
        return userMapper.addUser(user);
    }

    @Override
    public PageInfo<User> queryByPage(int page, int pageSize) {
        //改写语句实现分页查询
        PageHelper.startPage(page, pageSize);
        List<User> all = userMapper.queryUserList();
        return new PageInfo<User>(all);
    }
}
